/**
 * mbaobao.com Inc.
 * Copyright (c) 2011 All Rights Reserved.
 */
package com.peigen.web.depreciate.depreciate.dal.ibatis;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.peigen.web.depreciate.depreciate.dal.daointerface.DepreciateUserAttentionDAO;


// auto generated imports
import com.peigen.web.depreciate.depreciate.dal.dataobject.DepreciateUserAttentionDO;
import org.springframework.dao.DataAccessException;
import java.util.List;
import java.util.Map;
	import java.util.HashMap;
	
/**
 * An ibatis based implementation of dao interface <tt>com.peigen.web.depreciate.depreciate.dal.daointerface.DepreciateUserAttentionDAO</tt>.
 *
 * This file is generated by <tt>depreciate-dalgen</tt>, a DAL (Data Access Layer)
 * code generation utility specially developed for <tt>paygw</tt> project.
 * 
 * PLEASE DO NOT MODIFY THIS FILE MANUALLY, or else your modification may
 * be OVERWRITTEN by someone else. To modify the file, you should go to 
 * directory <tt>(project-home)/biz/dal/src/conf/dalgen</tt>, and 
 * find the corresponding configuration file (<tt>tables/depreciate_user_attention.xml</tt>). 
 * Modify the configuration file according to your needs, then run <tt>depreciate-dalgen</tt> 
 * to generate this file.
 *
 * @author peigen
 */ 
@SuppressWarnings({ "unchecked", "rawtypes" })

public class IbatisDepreciateUserAttentionDAO extends SqlMapClientDaoSupport implements DepreciateUserAttentionDAO {
	/**
	 *  Insert one <tt>DepreciateUserAttentionDO</tt> object to DB table <tt>depreciate_user_attention</tt>, return primary key
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>insert into depreciate_user_attention(id,user_id,user_attention_product_id,product_alias_name,status,raw_add_time,raw_update_time) values (?, ?, ?, ?, ?, ?, ?)</tt>
	 *
	 *	@param depreciateUserAttention
	 *	@return long
	 *	@throws DataAccessException
	 */	 
    public long insert(DepreciateUserAttentionDO depreciateUserAttention) throws DataAccessException {
    	if (depreciateUserAttention == null) {
    		throw new IllegalArgumentException("Can't insert a null data object into db.");
    	}
    	
        getSqlMapClientTemplate().insert("MS-DEPRECIATE-USER-ATTENTION-INSERT", depreciateUserAttention);

        return depreciateUserAttention.getId();
    }

	/**
	 *  Query DB table <tt>depreciate_user_attention</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, user_id, user_attention_product_id, product_alias_name, status, raw_add_time, raw_update_time from depreciate_user_attention where (id = ?)</tt>
	 *
	 *	@param id
	 *	@return DepreciateUserAttentionDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateUserAttentionDO findById(long id) throws DataAccessException {
        Long param = new Long(id);

        return (DepreciateUserAttentionDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-USER-ATTENTION-FIND-BY-ID", param);

    }

	/**
	 *  Query DB table <tt>depreciate_user_attention</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, user_id, user_attention_product_id, product_alias_name, status, raw_add_time, raw_update_time from depreciate_user_attention where (user_id = ?)</tt>
	 *
	 *	@param userId
	 *	@return List<DepreciateUserAttentionDO>
	 *	@throws DataAccessException
	 */	 
    public List<DepreciateUserAttentionDO> findByUserId(String userId) throws DataAccessException {

        return getSqlMapClientTemplate().queryForList("MS-DEPRECIATE-USER-ATTENTION-FIND-BY-USER-ID", userId);

    }

	/**
	 *  Query DB table <tt>depreciate_user_attention</tt> for records.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>select id, user_id, user_attention_product_id, product_alias_name, status, raw_add_time, raw_update_time from depreciate_user_attention where ((user_id = ?) AND (user_attention_product_id = ?))</tt>
	 *
	 *	@param userId
	 *	@param userAttentionProductId
	 *	@return DepreciateUserAttentionDO
	 *	@throws DataAccessException
	 */	 
    public DepreciateUserAttentionDO findByUserIdAndProductId(String userId, String userAttentionProductId) throws DataAccessException {
        Map param = new HashMap();

        param.put("userId", userId);
        param.put("userAttentionProductId", userAttentionProductId);

        return (DepreciateUserAttentionDO) getSqlMapClientTemplate().queryForObject("MS-DEPRECIATE-USER-ATTENTION-FIND-BY-USER-ID-AND-PRODUCT-ID", param);

    }

	/**
	 *  Update DB table <tt>depreciate_user_attention</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>update depreciate_user_attention set user_attention_product_id=?, product_alias_name=?, status=? where (id = ?)</tt>
	 *
	 *	@param userAttentionProductId
	 *	@param productAliasName
	 *	@param status
	 *	@param id
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int updateForId(String userAttentionProductId, String productAliasName, String status, long id) throws DataAccessException {
        Map param = new HashMap();

        param.put("userAttentionProductId", userAttentionProductId);
        param.put("productAliasName", productAliasName);
        param.put("status", status);
        param.put("id", new Long(id));

        return getSqlMapClientTemplate().update("MS-DEPRECIATE-USER-ATTENTION-UPDATE-FOR-ID", param);
    }

	/**
	 *  Delete records from DB table <tt>depreciate_user_attention</tt>.
	 *
	 *  <p>
	 *  The sql statement for this operation is <br>
	 *  <tt>delete from depreciate_user_attention where (user_id = ?)</tt>
	 *
	 *	@param userId
	 *	@return int
	 *	@throws DataAccessException
	 */	 
    public int deleteByUserIdForTest(String userId) throws DataAccessException {

        return getSqlMapClientTemplate().delete("MS-DEPRECIATE-USER-ATTENTION-DELETE-BY-USER-ID-FOR-TEST", userId);
    }

}